package cn.lzy.demo;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Description 通过 XML 方式配置
 * @Author lzy
 * @Date 2024/2/5 19:23
 * @Version
 **/
public class TestDemo01Xml {

    public static void main(String[] args) {
        ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
        // 根据 bean 的id获取该 bean 的别名
        String[] users = ctx.getAliases("user");
        for (String alias : users) {
            System.out.println("alias = " + alias);
        }
        Object user2 = ctx.getBean("user2");
        Object user3 = ctx.getBean("user3");
        System.out.println(user2 == user3);
    }
}
